package com.chinaunicom.create.prototype.deepcopy;

import java.io.Serializable;

/**
 * @author liry
 * @version 1.0
 * @date Created on 2022/7/19 14:14
 * Description: 重写 clone() 方法实现深度拷贝
 */
public class Person implements Serializable, Cloneable {
    private String name;
    
    private String tel;
    
    private int age;
    
    private String email;
    
    private DDept dept;
    
    @Override
    public Object clone() throws CloneNotSupportedException {
        Person clonePerson = (Person) super.clone();
        clonePerson.setDept((DDept) this.dept.clone());
        return clonePerson;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public DDept getDept() {
        return dept;
    }

    public void setDept(DDept DDept) {
        this.dept = DDept;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", tel='" + tel + '\'' +
                ", age=" + age +
                ", email='" + email + '\'' +
                ", dept=" + dept +
                '}';
    }
}
